#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long n;
long long arr[200010] = {};
bool f[200010] = {};
long long dfs(long long pos)
{
    if(pos == n + 1)
    {
        long long ans = 0;
        for(int i = 1;i <= n;i++)
        {
            for(int j = i - 1;j >= 1;j--)
            {
                if(f[i] == f[j])
                {
                    if(arr[i] == arr[j]) ans += arr[i];
                    break;
                }
            }
        }
        return ans;
    }
    long long x = dfs(pos + 1);
    f[pos] = 1;
    long long y = dfs(pos + 1);
    f[pos] = 0;
    return max(x,y);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T; scanf("%d",&T);
    while(T--)
    {
        scanf("%lld",&n);
        for(int i = 0;i <= n;i++) arr[i] = 0,f[i] = 0;
        for(int i = 1;i <= n;i++) scanf("%lld",&arr[i]);
        printf("%lld\n",dfs(1));
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
